#include "netdisk.h"

// 实现可靠的接收函数，确保接收指定长度的数据
int recvn(int netfd, void* buf, int length){
    int total = 0;
    char* p = (char*)buf;
    while(total < length){
        ssize_t sret = recv(netfd, p+total, length - total, 0);
        if(sret == 0){
            return 0;
        }
        total += sret;
    }
    return length;
}
